package snapex.core.mapper;

import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static snapex.core.mapper.EmployeeInfoDynamicSqlSupport.*;

import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import snapex.core.model.EmployeeInfo;

@Mapper
public interface EmployeeInfoMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<EmployeeInfo> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("EmployeeInfoResult")
    EmployeeInfo selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="EmployeeInfoResult", value = {
        @Result(column="staff_id", property="staffId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="staff_name", property="staffName", jdbcType=JdbcType.VARCHAR),
        @Result(column="email_address", property="emailAddress", jdbcType=JdbcType.VARCHAR),
        @Result(column="extension_no", property="extensionNo", jdbcType=JdbcType.VARCHAR),
        @Result(column="manager_id", property="managerId", jdbcType=JdbcType.VARCHAR),
        @Result(column="manager_name", property="managerName", jdbcType=JdbcType.VARCHAR),
        @Result(column="department_id", property="departmentId", jdbcType=JdbcType.VARCHAR),
        @Result(column="department", property="department", jdbcType=JdbcType.VARCHAR),
        @Result(column="hash_key", property="hashKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_timestamp", property="createTimestamp", jdbcType=JdbcType.TIMESTAMP)
    })
    List<EmployeeInfo> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(employeeInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, employeeInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String staffId_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, employeeInfo)
                .where(staffId, isEqualTo(staffId_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(EmployeeInfo record) {
        return insert(SqlBuilder.insert(record)
                .into(employeeInfo)
                .map(staffId).toProperty("staffId")
                .map(staffName).toProperty("staffName")
                .map(emailAddress).toProperty("emailAddress")
                .map(extensionNo).toProperty("extensionNo")
                .map(managerId).toProperty("managerId")
                .map(managerName).toProperty("managerName")
                .map(departmentId).toProperty("departmentId")
                .map(department).toProperty("department")
                .map(hashKey).toProperty("hashKey")
                .map(createTimestamp).toProperty("createTimestamp")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(EmployeeInfo record) {
        return insert(SqlBuilder.insert(record)
                .into(employeeInfo)
                .map(staffId).toPropertyWhenPresent("staffId", record::getStaffId)
                .map(staffName).toPropertyWhenPresent("staffName", record::getStaffName)
                .map(emailAddress).toPropertyWhenPresent("emailAddress", record::getEmailAddress)
                .map(extensionNo).toPropertyWhenPresent("extensionNo", record::getExtensionNo)
                .map(managerId).toPropertyWhenPresent("managerId", record::getManagerId)
                .map(managerName).toPropertyWhenPresent("managerName", record::getManagerName)
                .map(departmentId).toPropertyWhenPresent("departmentId", record::getDepartmentId)
                .map(department).toPropertyWhenPresent("department", record::getDepartment)
                .map(hashKey).toPropertyWhenPresent("hashKey", record::getHashKey)
                .map(createTimestamp).toPropertyWhenPresent("createTimestamp", record::getCreateTimestamp)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<EmployeeInfo>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, staffId, staffName, emailAddress, extensionNo, managerId, managerName, departmentId, department, hashKey, createTimestamp)
                .from(employeeInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<EmployeeInfo>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, staffId, staffName, emailAddress, extensionNo, managerId, managerName, departmentId, department, hashKey, createTimestamp)
                .from(employeeInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default EmployeeInfo selectByPrimaryKey(String staffId_) {
        return SelectDSL.selectWithMapper(this::selectOne, staffId, staffName, emailAddress, extensionNo, managerId, managerName, departmentId, department, hashKey, createTimestamp)
                .from(employeeInfo)
                .where(staffId, isEqualTo(staffId_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(EmployeeInfo record) {
        return UpdateDSL.updateWithMapper(this::update, employeeInfo)
                .set(staffId).equalTo(record::getStaffId)
                .set(staffName).equalTo(record::getStaffName)
                .set(emailAddress).equalTo(record::getEmailAddress)
                .set(extensionNo).equalTo(record::getExtensionNo)
                .set(managerId).equalTo(record::getManagerId)
                .set(managerName).equalTo(record::getManagerName)
                .set(departmentId).equalTo(record::getDepartmentId)
                .set(department).equalTo(record::getDepartment)
                .set(hashKey).equalTo(record::getHashKey)
                .set(createTimestamp).equalTo(record::getCreateTimestamp);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(EmployeeInfo record) {
        return UpdateDSL.updateWithMapper(this::update, employeeInfo)
                .set(staffId).equalToWhenPresent(record::getStaffId)
                .set(staffName).equalToWhenPresent(record::getStaffName)
                .set(emailAddress).equalToWhenPresent(record::getEmailAddress)
                .set(extensionNo).equalToWhenPresent(record::getExtensionNo)
                .set(managerId).equalToWhenPresent(record::getManagerId)
                .set(managerName).equalToWhenPresent(record::getManagerName)
                .set(departmentId).equalToWhenPresent(record::getDepartmentId)
                .set(department).equalToWhenPresent(record::getDepartment)
                .set(hashKey).equalToWhenPresent(record::getHashKey)
                .set(createTimestamp).equalToWhenPresent(record::getCreateTimestamp);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(EmployeeInfo record) {
        return UpdateDSL.updateWithMapper(this::update, employeeInfo)
                .set(staffName).equalTo(record::getStaffName)
                .set(emailAddress).equalTo(record::getEmailAddress)
                .set(extensionNo).equalTo(record::getExtensionNo)
                .set(managerId).equalTo(record::getManagerId)
                .set(managerName).equalTo(record::getManagerName)
                .set(departmentId).equalTo(record::getDepartmentId)
                .set(department).equalTo(record::getDepartment)
                .set(hashKey).equalTo(record::getHashKey)
                .set(createTimestamp).equalTo(record::getCreateTimestamp)
                .where(staffId, isEqualTo(record::getStaffId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(EmployeeInfo record) {
        return UpdateDSL.updateWithMapper(this::update, employeeInfo)
                .set(staffName).equalToWhenPresent(record::getStaffName)
                .set(emailAddress).equalToWhenPresent(record::getEmailAddress)
                .set(extensionNo).equalToWhenPresent(record::getExtensionNo)
                .set(managerId).equalToWhenPresent(record::getManagerId)
                .set(managerName).equalToWhenPresent(record::getManagerName)
                .set(departmentId).equalToWhenPresent(record::getDepartmentId)
                .set(department).equalToWhenPresent(record::getDepartment)
                .set(hashKey).equalToWhenPresent(record::getHashKey)
                .set(createTimestamp).equalToWhenPresent(record::getCreateTimestamp)
                .where(staffId, isEqualTo(record::getStaffId))
                .build()
                .execute();
    }
}